package com.wcar.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 
 * @TableName tb_coupon_codes
 */
@TableName(value ="tb_coupon_codes")
@Data
public class CouponCodes implements Serializable {
    /**
     * 每个优惠券的唯一标识符
     */
    @TableId(type = IdType.AUTO)
    private Integer couponId;

    /**
     * 对优惠券进行简要描述的名称
     */
    private String couponName;

    /**
     * 顾客用于兑换优惠券的唯一代码
     */
    private String couponCode;

    /**
     * 优惠券的类型，例如折扣、满减、赠品等
     */
    private String couponType;

    /**
     * 如果优惠券是折扣类型，指示折扣的金额
     */
    private BigDecimal discountAmount;

    /**
     * 如果优惠券是折扣类型，指示折扣的百分比
     */
    private BigDecimal discountPercentage;

    /**
     * 使用优惠券所需的最低订单金额
     */
    private BigDecimal minimumOrderAmount;

    /**
     * 优惠券生效的开始日期和时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;

    /**
     * 优惠券失效的结束日期和时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endDate;

    /**
     * 可以使用优惠券的次数限制
     */
    private Integer usageLimit;

    /**
     * 已经使用的优惠券次数统计(每有一个用户使用就加1）
     */
    private Integer usageCount;

    /**
     * 标记优惠券是否已经被使用，使用 1 表示已使用，0 表示未使用（也可能用不到）
     */
    private Integer isUsed;

    /**
     * 优惠券的创建日期和时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date creationDate;

    /**
     * 关联门店表的门店ID
     */
    private Integer storeId;

    /**
     * 关联的用户ID（可能用不到）
     */
    private Integer userId;
    @TableField(exist = false)
    private Store store;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CouponCodes other = (CouponCodes) that;
        return (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
            && (this.getCouponName() == null ? other.getCouponName() == null : this.getCouponName().equals(other.getCouponName()))
            && (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode()))
            && (this.getCouponType() == null ? other.getCouponType() == null : this.getCouponType().equals(other.getCouponType()))
            && (this.getDiscountAmount() == null ? other.getDiscountAmount() == null : this.getDiscountAmount().equals(other.getDiscountAmount()))
            && (this.getDiscountPercentage() == null ? other.getDiscountPercentage() == null : this.getDiscountPercentage().equals(other.getDiscountPercentage()))
            && (this.getMinimumOrderAmount() == null ? other.getMinimumOrderAmount() == null : this.getMinimumOrderAmount().equals(other.getMinimumOrderAmount()))
            && (this.getStartDate() == null ? other.getStartDate() == null : this.getStartDate().equals(other.getStartDate()))
            && (this.getEndDate() == null ? other.getEndDate() == null : this.getEndDate().equals(other.getEndDate()))
            && (this.getUsageLimit() == null ? other.getUsageLimit() == null : this.getUsageLimit().equals(other.getUsageLimit()))
            && (this.getUsageCount() == null ? other.getUsageCount() == null : this.getUsageCount().equals(other.getUsageCount()))
            && (this.getIsUsed() == null ? other.getIsUsed() == null : this.getIsUsed().equals(other.getIsUsed()))
            && (this.getCreationDate() == null ? other.getCreationDate() == null : this.getCreationDate().equals(other.getCreationDate()))
            && (this.getStoreId() == null ? other.getStoreId() == null : this.getStoreId().equals(other.getStoreId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
        result = prime * result + ((getCouponName() == null) ? 0 : getCouponName().hashCode());
        result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode());
        result = prime * result + ((getCouponType() == null) ? 0 : getCouponType().hashCode());
        result = prime * result + ((getDiscountAmount() == null) ? 0 : getDiscountAmount().hashCode());
        result = prime * result + ((getDiscountPercentage() == null) ? 0 : getDiscountPercentage().hashCode());
        result = prime * result + ((getMinimumOrderAmount() == null) ? 0 : getMinimumOrderAmount().hashCode());
        result = prime * result + ((getStartDate() == null) ? 0 : getStartDate().hashCode());
        result = prime * result + ((getEndDate() == null) ? 0 : getEndDate().hashCode());
        result = prime * result + ((getUsageLimit() == null) ? 0 : getUsageLimit().hashCode());
        result = prime * result + ((getUsageCount() == null) ? 0 : getUsageCount().hashCode());
        result = prime * result + ((getIsUsed() == null) ? 0 : getIsUsed().hashCode());
        result = prime * result + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode());
        result = prime * result + ((getStoreId() == null) ? 0 : getStoreId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", couponId=").append(couponId);
        sb.append(", couponName=").append(couponName);
        sb.append(", couponCode=").append(couponCode);
        sb.append(", couponType=").append(couponType);
        sb.append(", discountAmount=").append(discountAmount);
        sb.append(", discountPercentage=").append(discountPercentage);
        sb.append(", minimumOrderAmount=").append(minimumOrderAmount);
        sb.append(", startDate=").append(startDate);
        sb.append(", endDate=").append(endDate);
        sb.append(", usageLimit=").append(usageLimit);
        sb.append(", usageCount=").append(usageCount);
        sb.append(", isUsed=").append(isUsed);
        sb.append(", creationDate=").append(creationDate);
        sb.append(", storeId=").append(storeId);
        sb.append(", userId=").append(userId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}